function AvatarObject(theGame){
	var game = theGame;
	var location = null;
	var island = null;
	var ship = null;
	var speed = 0;
	var commodities = null;
	var crewMembers = null;
	var daysAtSea = 0;
	var heading = 0;
	var days = 0;
	var boundFor = null;
	var tradingCommodity = null;
	
	this.clear = function(){
		location = null;
		island = null;
		ship = null;
		speed = 0;
		commodities = null;
		crewMembers = null;
		daysAtSea = 0;
		heading = 0;
		days = 0;
		boundFor = null;
		tradingCommodity = null;
	};
	this.clear();
	
	this.getLocation = function(){return location;};
	this.getIsland = function(){return island;};
	this.setIsland = function(theIsland){island = theIsland;};
	this.clear = function(){
	};
	this.getShip = function(){
		return ship;
	};
	this.setShip = function(theShip){
		ship = theShip;
	};
	this.getHeading = function(){
		return heading;
	};
	this.setHeading = function(theHeading){
		heading = theHeading;
	};
	this.getSpeed = function(){
		return speed;
	};
	this.setSpeed = function(theSpeed){
		speed = theSpeed;
	};
	this.setMaximumSpeed = function(){
		this.setSpeed(this.getMaximumSpeed());
	};
	this.getMaximumSpeed = function(){
		return game.getShips().getShip(this.getShip()).getMaximumSpeed();
	};
	this.getMaximumTonnage = function(){
		return game.getShips().getShip(this.getShip()).getMaximumTonnage();
	};
	this.getAvailableTonnage = function(){
		return this.getMaximumTonnage() - this.getCommodities().getTonnage();
	};
	this.getDaysAtSea = function(){
		return daysAtSea;
	};
	this.setDaysAtSea = function(theDaysAtSea){
		daysAtSea = theDaysAtSea;
	};
	this.clearDaysAtSea = function(){
		this.setDaysAtSea(0);
	};
	this.incrementDaysAtSea = function(){
		this.setDaysAtSea(this.getDaysAtSea()+1);
	};
	this.getDays = function(){
		return days;
	};
	this.setDays = function(theDays){
		days = theDays;
	};
	this.clearDays = function(){
		this.setDays(0);
	};
	this.incrementDays = function(){
		this.setDays(this.getDays()+1);
	};
	this.setBoundFor = function(theIsland){
		boundFor = theIsland;
	};
	this.getBoundFor = function(){
		return boundFor;
	};
	this.clearBoundFor = function(){
		this.setBoundFor(null);
	};
	this.setTradingCommodity = function(theCommodity){
		tradingCommodity = theCommodity;
	};
	this.getTradingCommodity = function(){
		return tradingCommodity;
	};
	this.clearTradingCommodity = function(){
		this.setTradingCommodity(null);
	};
	this.getDistanceToIsland = function(theIsland){
		return this.getLocation().getDistanceBetween(game.getIslands().getIsland(theIsland).getLocation());
	};
	this.getHeadingToIsland = function(theIsland){
		return game.getUtilities().radiansToHeading(this.getLocation().getDirectionTo(game.getIslands().getIsland(theIsland).getLocation()));
	};
	this.getCommodities = function(){
		return commodities;
	};
	this.getCommodity = function(theCommodity){
		return this.getCommodities().getCommodity(theCommodity);
	};
	this.getCurrencyCommodity = function(){
		return this.getCommodity(game.getConfig().getCurrencyCommodity());
	};
	this.generate = function(){
		this.clear();
		
		//start in the middle of the world
		location = new LocationObject(game.getConfig().getCenterIslandX(),game.getConfig().getCenterIslandY());
		
		//find nearest island
		this.setIsland(game.getIslands().findNearestIsland(this.getLocation()));
		//tweak island to be located and visited
		game.getIslands().getIsland(this.getIsland()).setVisited();
		game.getIslands().getIsland(this.getIsland()).setLocated();
		
		//tweak location to coincide with island
		this.getLocation().copyLocation(game.getIslands().getIsland(this.getIsland()).getLocation());
		
		//get a ship
		this.setShip(game.getShips().generateAvatarShip());
		//set speed to maximum for ship
		this.setMaximumSpeed();
		
		//set commodities
		commodities = new AvatarCommoditiesObject(game);
		
		//set crew members
		crewMembers = new AvatarCrewMembersObject(game);
	}
	this.getGameData = function(){
		var data = {};
		data.location = location.getGameData();
		data.island = island;
		data.ship = ship;
		data.speed = speed;
		data.commodities = commodities.getGameData();
		data.crewMembers = crewMembers.getGameData();
		data.daysAtSea = daysAtSea;
		data.heading = heading;
		data.days = days;
		if(boundFor!=null){
			data.boundFor = boundFor;
		}
		if(tradingCommodity!=null){
			data.tradingCommodity = tradingCommodity;
		}
		return data;
	};
	this.setGameData = function(data){
	};

}
